package com.qf.servlet;

import com.qf.entity.Classes;
import com.qf.service.ClassesService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 执行班级修改的Servlet
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@WebServlet(urlPatterns = "/classesupdate")
public class ClassUpdateServlet extends HttpServlet {

    private ClassesService classesService = new ClassesService();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String clsName = req.getParameter("className");

        Classes classes = new Classes();
        classes.setId(Integer.parseInt(id));
        classes.setClassName(clsName);

        classesService.updateCls(classes);

        //跳转到列表页面
        resp.sendRedirect("classsequery");
    }
}
